<?
layout("/inc/layout.html",{title:sysTitle}){
?>

<div id="page-wrapper">
      <!--BEGIN TITLE & BREADCRUMB PAGE-->
      <div id="title-breadcrumb-option-demo" class="page-title-breadcrumb">
          <div class="page-header pull-left">
              <div class="page-title">公共基础字段管理</div>
          </div>
          <ol class="breadcrumb page-breadcrumb pull-left">
              <li><i class="fa fa-home"></i>&nbsp;<a href="main.html">首页</a>&nbsp;&nbsp;<i class="fa fa-angle-right"></i>&nbsp;&nbsp;</li>
              <li>知识库管理&nbsp;&nbsp;<i class="fa fa-angle-right"></i>&nbsp;&nbsp;</li>
              <li class="active">公共基础字段管理</li>
          </ol>
           
          <div class="clearfix"></div>
      </div>
      <!--END TITLE & BREADCRUMB PAGE-->
      <!--BEGIN CONTENT-->
      <div class="page-content">
      
      
      <div class="row mbl">
           <div class="col-lg-6">
               <div class="input-group input-group-sm mbs"><span class="input-group-btn">
               	<select id="queryParams" class="btn btn-danger dropdown-toggle" style="width :100px;">
               		 <option value="-1">筛选项&nbsp;<span class="caret"></span></option>
                    <option value="nameZh">中文名称</option>
                    <option value="nameEn">英文名称</option>
                    <option value="field">字段名称</option>
                
                    </select>
                   </span>
                   <input type="text" id="text" placeholder="请输入关键词..." class="form-control" /><span class="input-group-btn"><button type="button" data-toggle="dropdown" class="btn btn-success dropdown-toggle" onclick="get()">搜索</button></span>
               </div>
           </div>
           <div class="col-lg-6">
               <div class="tb-group-actions pull-right"><span>当前共<label id="pageSize"></label>条记录:</span>
                   <select id="pageNumber" class="table-group-action-input form-control input-inline input-small input-sm mlm" onchange="get()">
                       <option value="5">5</option>
                       <option value="10" >10</option>
                       <option value="15" >15</option>
                       <option value="25">25</option>
                       <option value="50" selected>50</option>
                   </select>&nbsp;
                    <button class="btn btn-sm btn-primary" onclick="kk('0')">新增
                   </button> 
               </div>
           </div>
       </div>
      
      <table class="table table-hover table-striped table-bordered table-advanced tablesorter mbn">
            <thead>
                <tr>
                  
                   <th  style="text-align:center;">序号</th>
                  	<th >中文名称</th> 
                    <th>英文名称</th>
                    <th >字段名称</th>
                    <th >数据类型</th>
                    <th >关联字典类</th>
                    <th >是否分面字段</th>
                    <th >是否普通检索字段</th>
                    <th >是否高级检索字段</th>
                    <th >是否二次检索字段</th>
                    <th >排序</th>
                    <th >可操作</th> 
                </tr>
            </thead>
             <tbody id="newspaperls"></tbody>
        </table>
<div id="dataNull" class="panel-body"
				style="height: 90px; line-height: 50px;" align="center">
				<span class='subtitle' style="font-size: 15px;">数据为空!</span>
		</div>
        <div id="page1" style="text-align: center; margin-top: 20px;"></div>
    </div>
                     
    <!--END CONTENT-->
    </div>
    
  <script>
   var curr;
   var id;
$(function(){
	list1();
});
function get() {  
          	list1(curr);
    }
function getlay( ) {  
            return id;
    }
			function kk(lid) {
				id = lid;
				layer.open({
					type : 2,
					area : [ '1050px', '630px' ],
					title:"公共基础字段添加或编辑",
					fix : false, //不固定
					scrollbar : false,
					shadeClose : true,
					move : false,
					skin : 'layui-layer-rim', //加上边框
					btn : [ '保存 ', '关闭' ],
					content : "knowledge-Common-DataFrom.html",
					yes: function(index,layer){
    	                  var iframeWin = parent.window[layer.find('iframe')[0]['name']];
    	                   iframeWin.Page();
    	              },
					cancel : function(index) {
					}
				});
			 }
			function del(id) {

				if (confirm("是否确认删除！！")) {
					jQuery.ajaxq("name",{
								type : "post",
								url : "./KnowledgeCommonDatadel.do",
								data : {
									"id" : id
								},
								dataType : "json",
								success : function(data) {
								if(data.result=="ok"){
									layer.msg("删除成功");
									list1(curr);
									}else
									{
									layer.msg("删除失败，有关联");
									}
								},
								error : function(data) {
									alert("请求失败");
								}
							});
				}

			}
			function list1(curr) {
				$.getJSON("./KnowledgeCommonDataList.do",
								{
									page : curr || 1,
									queryParams : $("#queryParams").val(),
									text : $("#text").val(),
									pageNumber : $("#pageNumber").val()
								},
								function(res) {
									//此处仅仅是为了演示变化的内容
									var str = "";

									$("#newspaperls").html("");
									if(res.listsize>0){
											$("#dataNull").hide();
										}else{
											$("#dataNull").show();
										}
									for ( var i = 0; i < res.listsize; i++) {
										var dictname='';
										
										for ( var j = 0; j < res.rdict.length; j++) {
											if(res.rdict[j].id == res.result[i].dictId && dictname == ''){
												dictname = res.rdict[j].nameZh;
											}
										}
										var dataTypename = '';
										for ( var j = 0; j < res.rdataType.length; j++) {
											if(res.rdataType[j].id == res.result[i].dataTypeId && dataTypename == ''){
												dataTypename = res.rdataType[j].nameZh;
											}
										}
										var faceted;
											if(res.result[i].faceted == 1){
												faceted ='是';
											}else{
												faceted ='否';
											}
										var generalSearchField;
											if(res.result[i].generalSearchField == 1){
												generalSearchField ='是';
											}else{
												generalSearchField ='否';
											}
										var advancedSearchField;
											if(res.result[i].advancedSearchField == 1){
												advancedSearchField ='是';
											}else{
												advancedSearchField ='否';
											}
										var searchWithinResultsField;
											if(res.result[i].searchWithinResultsField == 1){
												searchWithinResultsField ='是';
											}else{
												searchWithinResultsField ='否';
											}
										str += "<tr><td align=\"center\"> "
												+ (i + 1)
												+ "</td><td> <label >"
												+ res.result[i].nameZh
												+ "</label></td><td><label >"
												+ res.result[i].nameEn 
												+ "</label></td><td><label >"
												+ res.result[i].field
												+ "</label></td><td><label >"
												+ dataTypename
												+ "</label></td><td><label >"
												+ dictname
												+ "</label></td><td><label >"
												+ faceted
												+ "</label></td><td><label >"
												+ generalSearchField
												+ "</label></td><td><label >"
												+ advancedSearchField
												+ "</label></td><td><label >"
												+ searchWithinResultsField
												+ "</label></td><td><label >"
												+ res.result[i].sort
												+ "</label></td><td>"
												+ "<button type=\"button\" class=\"btn btn-default btn-xs\"onclick=\"del('"
												+ res.result[i].id
												+ "')\">"
												+ "删除"
												+ "</button>"
												+ "          <button type=\"button\" class=\"btn btn-default btn-xs\"  onclick=\"kk('"
												+ res.result[i].id
												+ "')\">"
												+ "编辑"
												+ "</button>"
												+ "</td></tr>";
									}
									$("#newspaperls").append(str);
									document.getElementById('pageSize').innerHTML=res.listsize;
									laypage({
										cont : document.getElementById('page1'), //容器。值支持id名、原生dom对象，jquery对象,
										pages : res.pageSize, //总页数
										skip : true, //是否开启跳页
										skin : 'molv', //加载内置皮肤，也可以直接赋值16进制颜色值，如:#c00
										curr : curr || 1,
										last: res.pageSize,
										groups : 6,//连续显示分页数
										jump : function(obj, first) { //触发分页后的回调
											if (!first) { //点击跳页触发函数自身，并传递当前页：obj.curr
												list1(obj.curr);
												var curr = obj.curr;
												curr = obj.curr;
											}
										}
									});
								});
			};
		</script>
<?} ?>

